<template>
	<view class="container">
		<uni-nav-bar title="申请咨询列表" @clickLeft="goHome" left-icon="left" backgroundColor="#fff" color="#000"
			statusBar="true"></uni-nav-bar>
			
		<view class="content" v-if="dataList.length">
			<scroll-view class="scrollView" scroll-y="true" :style="{height: setcollapseheight() - 10 + 'px'}">
				<view class="item" v-for="(item,index) in dataList" :key="index">
					<view class="title">
						{{ item.content }}
					</view>
					<view class="btn-box">
						<view class="button1" @click="agree(item, true)">同意</view>
						<view class="button2" @click="agree(item, false)">不同意</view>
					</view>
				</view>
			</scroll-view>
		</view>

		<view v-else class="facility-view-nodata">
			<image class="facility-view-blankimg" mode="widthFix" src="@/static/blank.png"></image>
			<view class="facility-view-nodata-line">
				暂无数据
			</view>
		</view>
		
		<bottomTabar></bottomTabar>
	</view>

</template>

<script>
	import chartApi from '@/api/socialized-servce/specialist-consultation/chart/index.js'
	import bottomTabar from '../../components/bottom-tabar/index.vue'
	export default {
		components: {
			bottomTabar
		},
		data() {
			return {
				dataList: []
			}
		},
		mounted() {
			this.queryAuditList()
		},
		methods: {
			onPullDownRefresh() {
				this.queryAuditList()
				setTimeout(function() {
					uni.stopPullDownRefresh()
				}, 1000)
			},
			queryAuditList() {
				chartApi.queryAuditList().then(res => {
					this.dataList = res.data
				})
			},
			goHome() {
				uni.reLaunch({
					url: '/pages/socialized-service/selection-system/selection-system'
				})
			},
			// 审核
			agree(data, flag) {
				let txt = flag ? "" : "不";
				uni.showModal({
					title: '提示',
					content: `确认${txt}同意该申请吗？`,
					// labelColor: '#3385e3',
					cancelText: "取消",
					confirmText: "确认",
					// confirmColor: '#f55850',
					// cancelColor: '#39B54A',
					success(res) {
						if (res.confirm) {
							chartApi.audit({
								id: data.id,
								flag
							}).then(res => {
								uni.showToast({
									title: res.msg,
									icon: 'none'
								})
								this.queryAuditList();
							});
						}
					}
				});
			},
			setcollapseheight() {
				let winHeight = 0
				let topheightone = uni.upx2px(136)
				uni.getSystemInfo({
					success: function(res) {
						winHeight = res.windowHeight
					}
				})
				let oldHeight = uni.upx2px(136)
				winHeight = parseInt(winHeight) - topheightone - oldHeight
				// #ifndef H5
				winHeight = winHeight - 10
				// #endif
				return winHeight
			},
		},
	}
</script>

<style lang="scss" scoped>
	.container {
		background: #F5F6FA;
		.content {
			padding: 0 40rpx;
			margin-top: 20rpx;
			.item {
				background: #ebf1ff;
				margin-bottom: 30rpx;
				padding: 30rpx;
				border: 2rpx solid #eee;
				.btn-box {
					text-align: right;
					margin-top: 20rpx;
					.button1 {
						padding: 6rpx 30rpx;
						width: fit-content;
						display: inline-block;
						background: linear-gradient(155deg, #adbdff 0%, #464ab1 100%);
						border-radius: 46rpx;
						color: #ffffff;
						margin-right: 20rpx;
					}
					.button2 {
						padding: 6rpx 30rpx;
						width: fit-content;
						display: inline-block;
						background: #ffffff;
						border-radius: 46rpx;
						color: #464ab1;
					}
				}
			}
		}
	}
</style>